<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="5" :lg="7" :md="8" :sm="24">
            <a-form-item label="周会标题">
              <a-input placeholder="请输入周会标题" style="width: 200px" v-model="queryParam.weeklyMeetTitle"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="5" :lg="7" :md="8" :sm="24">
            <a-form-item label="待办事项">
              <a-input placeholder="请输入待办事项" style="width: 200px" v-model="queryParam.representation"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="5" :lg="8" :md="8" :sm="24">
            <a-form-item label="执行人">
              <a-input placeholder="请输入执行人" style="width: 200px" v-model="queryParam.executor"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="5" :lg="7" :md="8" :sm="24">
            <a-form-item label="分类:">
              <a-select placeholder="请选择工作类型" style="width: 200px" @change="handleChange"
                v-model="queryParam.classification" allowClear>
                <a-select-option value="运维">
                  运维
                </a-select-option>
                <a-select-option value="开发">
                  开发
                </a-select-option>
                <a-select-option value="其它">
                  其它
                </a-select-option>
              </a-select>
              <!-- <a-input placeholder="请输入分类（运维、开发、其它）" style="width: 200px" v-model="queryParam.classification"></a-input> -->
            </a-form-item>
          </a-col>
          <!-- <template v-if="toggleSearchStatus"> -->
            
        </a-row>
        <a-row :gutter="24">
          
          <a-col :xl="5" :lg="7" :md="8" :sm="24">
            <a-form-item label="执行状态：">
              <!-- <a-input placeholder="请输入执行状态（未开始、执行中、已完成）" style="width: 200px" v-model="queryParam.executionStatus"> -->
              <a-select placeholder="请选择执行状态" style="width: 200px" v-model="queryParam.executionStatus" allowClear>
                <a-select-option value="未开始">
                  未开始
                </a-select-option>
                <a-select-option value="执行中">
                  执行中
                </a-select-option>
                <a-select-option value="已完成">
                  已完成
                </a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <!-- </template> -->
          <a-col :xl="5" :lg="7" :md="8" :sm="24">
            <!-- <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons"> -->
            <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
            <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
            <!-- <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a> -->
            <!-- </span> -->
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd('会议')" type="primary" icon="plus">新增</a-button>
      <a-button type="primary" icon="download" @click="handleExportXls('周报反馈系统')">导出</a-button>
      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl"
        @change="handleImportExcel">
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload>
      <!-- 高级查询区域 -->
      <!-- <j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery">
      </j-super-query> -->
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <!-- <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel">
            <a-icon type="delete" />删除
          </a-menu-item>
        </a-menu> -->
        <!-- <a-button style="margin-left: 8px"> 批量操作
          <a-icon type="down" />
        </a-button> -->
        <a-button style="margin-left: 8px" @click="batchComplete"> 批量完成
        </a-button>
      </a-dropdown>
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-button style="margin-left: 8px" @click="batchDel"> 批量删除
        </a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{
            selectedRowKeys.length
        }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table ref="table" size="middle" :scroll="{ x: true }" bordered rowKey="id" :columns="columns"
        :customRow="customRow" :dataSource="dataSource" :pagination="ipagination" :loading="loading"
        :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }" class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text,record">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" :preview="record.id" height="25px" alt=""
            style="max-width:80px;font-size: 12px;font-style: italic;" />
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">
            下载
          </a-button>
        </template>
        <!-- 执行状态插槽 -->
        <template slot="executionStatus" slot-scope="text">
          <a-tag v-if="text == '已完成'" color="blue">已完成</a-tag>
          <a-tag v-if="text == '执行中'" color="orange">执行中</a-tag>
          <a-tag v-if="text == '未开始'" color="red">未开始</a-tag>
        </template>

        <!-- <div class="LeaveOut" :title="text" slot="representation" slot-scope="text, record">
          <div :style="{ textAlign: 'center' }">{{ text }}</div>
        </div> -->
        <!-- <span slot="representation" slot-scope="text">
            <span :title="text">{{ text}}</span>
          </span> -->

        <span slot="representation" slot-scope="text, record">
          <a-tooltip>
            <template slot="title">
              {{ record.representation }}
            </template>
            <div class="multi-ellipsis">{{ record.representation }}</div>
          </a-tooltip>
        </span>

        <span slot="action" slot-scope="text, record">
          <a v-if="record.executionStatus != '已完成'" @click="handleComplete(record.id)">点击完成</a>
          <a-divider type="vertical" />
          <a @click="handleEdit(record)">编辑</a>
          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多
              <a-icon type="down" />
            </a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="handleDetail(record)">详情</a>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>

      </a-table>
    </div>

    <weekly-report-feedback-modal ref="modalForm" @ok="modalFormOk"></weekly-report-feedback-modal>
  </a-card>
</template>

<script>

import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import WeeklyReportFeedbackModal from './modules/WeeklyReportFeedbackModal'

export default {
  name: 'WeeklyReportFeedbackList',
  mixins: [JeecgListMixin, mixinDevice],
  components: {
    WeeklyReportFeedbackModal
  },
  data() {
    return {
      description: '周报反馈系统管理页面',
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: "center",
          customRender: function (t, r, index) {
            return parseInt(index) + 1;
          }
        },
        {
          title: '周会标题',
          align: "center",
          dataIndex: 'weeklyMeetTitle'
        },
        {
          title: '待办事项',
          align: "center",
          width: 250,
          dataIndex: 'representation',
          scopedSlots: { customRender: 'representation' }
          //     onCell: ()=>{
          //   return {
          //     style:{
          //       maxWidth: 100,
          //       overflow: 'hidden',
          //       whiteSpace: 'nowrap',
          //       textOverflow: 'ellipsis',
          //       cursor: 'pointer'
          //     }
          //   }
          // },
          //     render: (text)=><Tooltip placement="topLeft" title={text}>{text}</Tooltip>
        },
        {
          title: '预估时间',
          align: "center",
          dataIndex: 'estimatedTime',
          customRender: function (text) {
            return !text ? "" : (text.length > 10 ? text.substr(0, 10) : text)
          }
        },
        {
          title: '实际完成时间',
          align: "center",
          dataIndex: 'actualCompletionTime'
        },
        {
          title: '执行人',
          align: "center",
          dataIndex: 'executor'
        },
        {
          title: '最后截止时间',
          align: "center",
          dataIndex: 'deadline'
        },
        {
          title: '分类',
          align: "center",
          dataIndex: 'classification'
        },
        {
          title: '执行状态',
          align: "center",
          dataIndex: 'executionStatus',
          scopedSlots: { customRender: 'executionStatus' }
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: "center",
          fixed: "right",
          width: 147,
          scopedSlots: { customRender: 'action' }
        }
      ],
      url: {
        // list: "/ch/weeklyReportFeedback/list",
        list: "/ch/weeklyReportFeedback/mpList",
        delete: "/ch/weeklyReportFeedback/delete",
        deleteBatch: "/ch/weeklyReportFeedback/deleteBatch",
        exportXlsUrl: "/ch/weeklyReportFeedback/exportXls",
        importExcelUrl: "ch/weeklyReportFeedback/importExcel",

      },
      dictOptions: {},
      superFieldList: [],
    }
  },
  created() {
    this.getSuperFieldList();
   
  },
  mounted(){
    
    if (localStorage.getItem('record')) {
      console.log("JSON.parse(localStorage.getItem('record'))",JSON.parse(localStorage.getItem('record')));
      this.handleEdit(JSON.parse(localStorage.getItem('record')))
    }
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    },
  },
  methods: {
    //鼠标双击事件
    customRow(record, index) {
      return {
        on: {
          // 双击
          dblclick: (event) => {
            console.log("record----", record);
            console.log("index", index);
            console.log("event", event);
            // 编辑表单
            console.log('编辑表单');
            
            this.handleEdit(record)
          },
        },
        // on: {
        //   // 单击
        //   click: (event) => {
        //     // 详情表单
        //     console.log('详情表单');
        //     this.handleDetail(record)
        //   },
        // }
      }
    },
    initDictConfig() {
    },
    getSuperFieldList() {
      let fieldList = [];
      fieldList.push({ type: 'string', value: 'weeklyMeetTitle', text: '周会标题', dictCode: '' })
      fieldList.push({ type: 'Text', value: 'representation', text: '待办事项', dictCode: '' })
      fieldList.push({ type: 'date', value: 'estimatedTime', text: '预估时间' })
      fieldList.push({ type: 'datetime', value: 'actualCompletionTime', text: '实际完成时间' })
      fieldList.push({ type: 'string', value: 'executor', text: '执行人', dictCode: '' })
      fieldList.push({ type: 'datetime', value: 'deadline', text: '最后截止时间' })
      fieldList.push({ type: 'string', value: 'classification', text: '分类（运维、开发、其它）', dictCode: '' })
      fieldList.push({ type: 'string', value: 'executionStatus', text: '执行状态（未开始、执行中、已完成）', dictCode: '' })
      this.superFieldList = fieldList
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';

.LeaveOut {
  overflow: hidden;
  /* 隐藏溢出*/
  /* height: 25px;  */
  width: 250px;
  white-space: nowrap;
  overflow: auto;
}
.multi-ellipsis {
  /* width: 250px; */
  /* maxWidth: '100%'; */
  white-space: nowrap;
  /* overflow : hidden; */
  text-overflow: ellipsis;
  width: 250px;
  display: -webkit-box;
  -webkit-line-clamp: 2; 
  /* // 超出两行则以...形式隐藏 */
  -webkit-box-orient: vertical;
  cursor: pointer;
  overflow: auto;
}
</style>